﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Infrastructure
{
    /// <summary>
    /// Linq 表达式.
    /// </summary>
    public static class LinqExtensions
    {
        /// <summary>
        ///  IEnumerable<typeparamref name="T"/>循环.
        /// </summary>
        /// <typeparam name="T">类型.</typeparam>
        /// <param name="source">循环列表.</param>
        /// <param name="action">执行委托.</param>
        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            if (action == null)
            {
                return;
            }

            foreach (var element in source)
            {
                action(element);
            }
        }
    }
}
